/**
 * Created on 27 sept. 2006 -- 14:59:14
 * Author: avezier (Inovatel)
 */
package antoine.ear.keyboard;

import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.Iterator;

import antoine.ear.GUI;
import antoine.ear.Main;
import antoine.ear.exo.OneNoteSeq;

public class KeyboardListener implements MouseListener {

    private Keyboard keyboard;
        
    public KeyboardListener(Keyboard keyboard) {
        this.keyboard = keyboard;
    }

    public void mouseClicked(MouseEvent arg0) {
		GUI gui = GUI.getInstance();

        Iterator ite = keyboard.getNotes().values().iterator();
        System.out.println("Cilck! ");
        Note note = null;
        boolean found = false;
        while (ite.hasNext()){
            note = (Note)ite.next();
            if (note.contains(arg0.getPoint())){
                found = true;
                break;
            }
        }
        if (found){
            gui.soluceMode = true;
            new PlayNote(note.getIndex()).start();
        }
    }

    public void mousePressed(MouseEvent arg0) {

    }

    public void mouseReleased(MouseEvent arg0) {

    }

    public void mouseEntered(MouseEvent arg0) {
    }

    public void mouseExited(MouseEvent arg0) {
    }

}
